$(function () {
    $.get('http://127.0.0.1:5000/admin', data => {
        console.log(data);
        $('.photo>img').attr('src', data[0].photo)
        $('#nickname').html(data[0].name)
        $('.article_length_num').html(data[1])
    })

    let strItem = ''
    $.get('http://127.0.0.1:5000/blog/abstract', data => {
        console.log(data);
        data.forEach(val => {
            if(val.id % 2 ===0){
                strItem +=`
                <div class="item fanzhuan">
                <div class="img">
                <a href="./details.html?id=${val.id}">
                  <img src="${val.bgUrl}" alt="">
                </a>
                </div>
                <div class="article_content">
                    <h3>
                      <a href="./details.html?id=${val.id}">${val.title}</a>
                    </h3>
                    <div class="article_info">
                      <spen class="release_time"><i></i>${val.publishTime}</spen>
                      <span class="dividing_line">|</span>
                      <span class="item_tags"></span>
                  </div>
                  <div class="content">${val.abstract}</div>
                </div>
              </div>
                `
            }else {
                strItem +=`
                <div class="item">
                <div class="img">
                  <a href="">
                    <img src="${val.bgUrl}" alt="">
                  </a>
                </div>
                <div class="article_content">
                    <h3>
                      <a href="./details.html?id=${val.id}">${val.title}</a>
                    </h3>
                    <div class="article_info">
                      <spen class="release_time"><i></i>${val.publishTime}</spen>
                      <span class="dividing_line">|</span>
                      <span class="item_tags"></span>
                  </div>
                  <div class="content">${val.abstract}</div>
                </div>
              </div>
                `
            }
        });
        $('.article').html(strItem)
    })




})

